﻿using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using Cosmos.Hardware;
using Cosmos.Hardware.BlockDevice;

namespace eOS
{
    public class Kernel : Sys.Kernel
    {
        protected override void BeforeRun()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.WriteLine("eOS is starting up...");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.WriteLine("eOS Mint");
            Console.WriteLine("Version [0.0.1]");
            Console.WriteLine("<C> 2015 ElectroSystems.");
            Console.WriteLine("Type 'help' for a list of commands.");
        }

        protected override void Run()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.BackgroundColor = ConsoleColor.Red;
            Console.Write("eOSMint> ");
            string command = Console.ReadLine();
            if (command == "help")
            {
                Console.WriteLine("eOS Mint List Of Commands:");
                Console.WriteLine("help - Display a list of commands");
                Console.WriteLine("hello - Display a test text");
                Console.WriteLine("clearconsole - Clears the console");
                Console.WriteLine("shutdown - Shuts down the system");
                Console.WriteLine("about - Shows information about the system");
                Console.WriteLine("reboot - Restart the system");
                Console.WriteLine("taskmgr - System task manager");
            }
            if (command == "about")
            {
                Console.WriteLine("eOS Mint");
                Console.WriteLine("Version [0.0.1]");
                Console.WriteLine("<C> 2015 ElectroSystems.");
                Console.WriteLine("Website: http://eOSMint.codeplex.com");
            }
            if (command == "taskmgr")
            {
                Console.WriteLine("eOS Task Manager");
                Console.WriteLine("Current Processes");
                Console.WriteLine("System");
                Console.WriteLine("To End A Process, Type 'endprocess <processname>'. (all lowercase)");
            }
            if (command == "endprocess system")
            {
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.BackgroundColor = ConsoleColor.Red;
                Console.WriteLine("A system error has occured. Press any key to continue. Here is a description of the error: An important task running was ended. Please reboot the system.");
                this.Stop();
                Cosmos.Core.Bootstrap.CPU.Halt();
            }
            if (command == "clearconsole")
            {
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
            }
            if (command == "hello")
                Console.WriteLine("eOS> Hello, World!");
            if (command == "reboot")
            {
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                Console.WriteLine("Rebooting...");
                this.Stop();
                Cosmos.Core.Bootstrap.CPU.Reboot();
            }
            if (command == "shutdown")
            {
                Console.WriteLine("eOS> Shutting Down... [          ]");
                Console.WriteLine("eOS> Shutting Down... [          ]");
                Console.WriteLine("eOS> Shutting Down... [          ]");
                Console.WriteLine("eOS> Shutting Down... [-         ]");
                Console.WriteLine("eOS> Shutting Down... [-         ]");
                Console.WriteLine("eOS> Shutting Down... [-         ]");
                Console.WriteLine("eOS> Shutting Down... [--        ]");
                Console.WriteLine("eOS> Shutting Down... [--        ]");
                Console.WriteLine("eOS> Shutting Down... [--        ]");
                Console.WriteLine("eOS> Shutting Down... [---       ]");
                Console.WriteLine("eOS> Shutting Down... [---       ]");
                Console.WriteLine("eOS> Shutting Down... [---       ]");
                Console.WriteLine("eOS> Shutting Down... [----      ]");
                Console.WriteLine("eOS> Shutting Down... [----      ]");
                Console.WriteLine("eOS> Shutting Down... [----      ]");
                Console.WriteLine("eOS> Shutting Down... [-----     ]");
                Console.WriteLine("eOS> Shutting Down... [-----     ]");
                Console.WriteLine("eOS> Shutting Down... [-----     ]");
                Console.WriteLine("eOS> Shutting Down... [------    ]");
                Console.WriteLine("eOS> Shutting Down... [------    ]");
                Console.WriteLine("eOS> Shutting Down... [------    ]");
                Console.WriteLine("eOS> Shutting Down... [-------   ]");
                Console.WriteLine("eOS> Shutting Down... [-------   ]");
                Console.WriteLine("eOS> Shutting Down... [-------   ]");
                Console.WriteLine("eOS> Shutting Down... [--------  ]");
                Console.WriteLine("eOS> Shutting Down... [--------  ]");
                Console.WriteLine("eOS> Shutting Down... [--------  ]");
                Console.WriteLine("eOS> Shutting Down... [--------- ]");
                Console.WriteLine("eOS> Shutting Down... [--------- ]");
                Console.WriteLine("eOS> Shutting Down... [--------- ]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("eOS> Shutting Down... [----------]");
                Console.WriteLine("System Shut Down. Press Any Key To Continue...");
                this.Stop();
                Cosmos.Core.Bootstrap.CPU.Halt();
            }
            if (command == "endprocess system")
            {
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.BackgroundColor = ConsoleColor.Red;
                Console.WriteLine("A system error has occured. Press any key to continue. Here is a description of the error: An important task running was ended. Please reboot the system.");
                this.Stop();
                Cosmos.Core.Bootstrap.CPU.Halt();
            }
        }
    }
}
